using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using DanielSig.UnityExtensions;
using DanielSig;

public class SpawnPool : MonoBehaviour
{
	public static Dictionary<Vector2, SpawnPool> Pool = new Dictionary<Vector2, SpawnPool>();
	
	public static bool IsFreeSpace(Vector2 pos)
	{
		if(pos.x.IsBetween(-1, 16) && pos.y.IsBetween(-1,16))
		{
			return !Pool.ContainsKey(pos);
		}
		return false;
	}
	
	private Vector2 _key;
	
	void Awake()
	{
		_key = transform.position.XZ();
		Pool.Add(_key, this);
	}
	void OnDestroy()
	{
		Pool.Remove(_key);
	}
}
